package com.example.recyclerdemo.room;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

@Dao
public interface StudentRoomDao {
    @Query("select * from stu_room")
    List<StudentEntity> getAll();

    //根据条件进行查询，使用引|拼接字符串
    @Query("select * from stu_room where student_name like '%'||:kw||'%' or classmate like '%'||:kw||'%'")
    List<StudentEntity> getAll(String kw);

    @Insert
    void insert(StudentEntity student);

    //根据student的id更新所有列的值
    @Update()
    void update(StudentEntity student);

    //更新年龄
    @Query("delete from stu_room where id=:id")
    void update(int id);

    //根据id进行删除
    @Query("delete from stu_room where id =id")
    void delete(int id);

    @Delete
    void delete(StudentEntity student);
}
